package com.sugon.stream;

import com.sugon.entity.Employee;
import java.util.ArrayList;
import java.util.Comparator;


public class TestComparator {

    public static void main(String[] args) {
        ArrayList<Employee> list = new ArrayList<>();
        list.add(new Employee("yangj", 20, 1E8));
        list.add(new Employee("xuem", 21, 1E10));
        list.add(new Employee("fengch", 22, 1E10));

/*
       list.sort((e1,e2)-> e1.getAge()-e2.getAge());

       list.sort(new Comparator<Employee>() {
           @Override
           public int compare(Employee o1, Employee o2) {
               return 0;
           }
       });
       list.forEach(new Consumer<Employee>() {
            @Override
            public void accept(Employee employee) {
                System.out.println(employee);
            }
        });
         list.forEach(e-> System.out.println(e));
        list.forEach(System.out::println);

        Comparator<Employee> c1 = Comparator.comparingInt(new ToIntFunction<Employee>() {
            @Override
            public int applyAsInt(Employee e) {
                return e.getAge();
            }
        });
        Comparator<Employee> c2 = Comparator.comparingInt(e->e.getAge());

        Comparator<Employee> c3 = Comparator.comparingInt(Employee::getAge);
        list.sort(c1);
        list.forEach(System.out::println);*/


        //  list.sort(Comparator.comparingDouble(Employee::getSalary).reversed());

        //  list.sort(Comparator.comparing(Employee::getName));
        //list.forEach(out::println);

        Comparator<Employee> c4 = Comparator.comparingDouble(Employee::getSalary);
        Comparator<Employee> c5 = Comparator.comparingInt(Employee::getAge);
        list.sort(c4.thenComparing(c5));
        list.forEach(System.out::println);
    }
}
                   /* Double networkInIO = (Double) dayDate.getJSONArray("networkInIO").toArray()[0];
                    Double networkInIO = (Double) dayDate.getJSONArray("networkInIO").toArray()[0];
                    Double networkInIO = (Double) dayDate.getJSONArray("networkInIO").toArray()[0];
                    Double networkInIO = (Double) dayDate.getJSONArray("networkInIO").toArray()[0];*/
